package app.beit.finportal.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import app.beit.finportal.bean.SlidesBean;
import app.beit.finportal.dao.SlidesDao;
import app.beit.finportal.entity.Slides;
import app.beit.finportal.service.convert.SlidesConvert;

public class SlidesService {

	@Autowired
	private SlidesDao slidesDao;
	
	public List<SlidesBean> getAllBackdoor() throws Exception{
		final List<Slides> entities = this.slidesDao.getAllBackdoor();
		if(entities != null && entities.size() > 0){
			return SlidesConvert.entityToBean(entities);
		}
		
		return null;
	}
	
	public List<SlidesBean> getAll() throws Exception{
		final List<Slides> entities = this.slidesDao.getAll();
		if(entities != null && entities.size() > 0){
			return SlidesConvert.entityToBean(entities);
		}
		
		return null;
	}
	
	public List<SlidesBean> getAllLastedDate() throws Exception{
		final List<Slides> entities = this.slidesDao.getAllLastestDate();
		if(entities != null && entities.size() > 0){
			return SlidesConvert.entityToBean(entities);
		}
		
		return null;
	}
	
	public SlidesBean getById(final String id) throws Exception{
		final Slides entities = this.slidesDao.getById(id);
		if(entities != null){
			return SlidesConvert.entityToBean(entities);
		}
		
		return null;
	}
	
	public void add(final SlidesBean bean) throws Exception{
		this.slidesDao.add(SlidesConvert.beanToEntity(bean));
	}
	
	public void update(final SlidesBean bean) throws Exception{
		this.slidesDao.update(SlidesConvert.beanToEntity(bean));
	}
	
	public void delete(final SlidesBean bean) throws Exception{
		this.slidesDao.delete(SlidesConvert.beanToEntity(bean));
	}
	
//	public NewsBean getById(final String id) throws Exception{
//		final News entities = this.newsDao.getById(id);
//		if(entities != null){
//			return NewsConvert.entityToBean(entities);
//		}
//		
//		return null;
//	}
//	
//	public void add(final NewsBean bean) throws Exception{
//		this.newsDao.add(NewsConvert.beanToEntity(bean));
//	}
//	
//	public void update(final NewsBean bean) throws Exception{
//		this.newsDao.update(NewsConvert.beanToEntity(bean));
//	}
//	
//	public void delete(final NewsBean bean) throws Exception{
//		this.newsDao.delete(NewsConvert.beanToEntity(bean));
//	}
}
